//
//  HEMyOrderAddSubOrderCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/6.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEMyOrderAddSubOrderCell.h"

@interface HEMyOrderAddSubOrderCell ()

@property (nonatomic, strong) UILabel *orderLb;
@property (nonatomic, strong) UILabel *addTimeLb;
@property (nonatomic, strong) UILabel *addCountLb;
@property (nonatomic, strong) YYLabel *addPriceLb;
@property (nonatomic, strong) UILabel *statusLb;

@end

@implementation HEMyOrderAddSubOrderCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
         self.selectionStyle = UITableViewCellSelectionStyleNone;
         [self initUI];
     }
     return self;;
}

- (void)initUI {
    
    _orderLb = [UILabel new];
    _orderLb.font = DYFont(16);
    _orderLb.text = @"订单号：";
    _orderLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview:_orderLb];
    
    _statusLb = [UILabel new];
    _statusLb.font = DYFont(16);
    _statusLb.text = @"-";
    _statusLb.textColor = CNavBgColor;
    [self.contentView addSubview:_statusLb];
    
    [_orderLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(20);
        make.right.equalTo(_statusLb.mas_left).mas_offset(-5);
    }];
    
    [_statusLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    UIView *headLine = [UIView new];
    headLine.backgroundColor = CSplitLineColor;
    [self.contentView addSubview:headLine];

    [headLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_orderLb.mas_bottom).mas_offset(10);
        make.height.mas_offset(1);
        make.left.equalTo(_orderLb);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    //
    _addTimeLb = [UILabel new];
    _addTimeLb.font = DYFont(16);
    _addTimeLb.text = @"补单时间：";
    _addTimeLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_addTimeLb];
    
    _addCountLb = [UILabel new];
    _addCountLb.font = DYFont(16);
    _addCountLb.text = @"补单数量：";
    _addCountLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_addCountLb];
    
    _addPriceLb = [YYLabel new];
    _addPriceLb.font = DYFont(16);
    _addPriceLb.text = @"补单金额：";
    _addPriceLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_addPriceLb];
    
    [_addTimeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headLine.mas_bottom).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(20);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [_addCountLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_addTimeLb.mas_bottom).mas_offset(5);
        make.left.equalTo(self.contentView).mas_offset(20);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [_addPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_addCountLb.mas_bottom).mas_offset(5);
        make.left.equalTo(self.contentView).mas_offset(20);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    
    
    UIView *footerLine = [UIView new];
    footerLine.backgroundColor = CSplitLineColor;
    [self.contentView addSubview:footerLine];
    
    [footerLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_addPriceLb.mas_bottom).mas_offset(10);
        make.height.mas_offset(1);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.bottom.equalTo(self.contentView).mas_offset(-15);
    }];
}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
    NSInteger a = indexPath.row - 1;

    HEOrderChildInfo *model = self.formModel.od_details.childInfo[a];
    
    if (model == nil) {
        return;
    }
    
    _orderLb.text = [NSString stringWithFormat:@"订单号：%@", model.orderNo];
    _addTimeLb.text = [NSString stringWithFormat:@"补单时间：%@", [NSDate timestampToDate:model.create_date formaterMode:NSDateFormaterModeDefault]];
    _addCountLb.text = [NSString stringWithFormat:@"补单数量：%ld", model.number];
    _addPriceLb.attributedText = model.KtotalAmount;
    _statusLb.text = model.KStatusText;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
